from django.db import models

# 执行创建表的命令
# 执行迁移命令 1 python manage.py makemigrations 2 python manage.py migrate
# Create your models here.


"""部门"""
class Department(models.Model):
    title = models.CharField(verbose_name="部门", max_length=32)
    def __str__(self):
        return self.title

"""员工"""

class UserInfo(models.Model):
    name = models.CharField(verbose_name="姓名", max_length=16)
    password = models.CharField(verbose_name="密码", max_length=64)
    age =models.IntegerField(verbose_name="年龄")
    account = models.DecimalField(verbose_name="账户余额", max_digits=10, decimal_places=2,default=0)
    #年月日时分秒
    # create_time = models.DateTimeField(verbose_name="入职时间")
    # 年月日
    create_time = models.DateField(verbose_name="入职时间")
    #关联部门ID
    # null=True,blank=True 这一列可以为空
    # on_delete=models.SET_NULL 当部门表被删除了，可以为空
    # on_delete=models.CASCADE 当部门表被删除了，这列也跟着删除

    depart = models.ForeignKey(verbose_name="部门",to="Department",to_field="id",null=True,blank=True,on_delete=models.SET_NULL)

    # 性别django 中约束 用元组
    gender_choices = (
        (0,"女"),
        (1,"男"),
    )
    gender=models.SmallIntegerField(verbose_name="性别",choices=gender_choices)



"""靓号表"""
class Pretty(models.Model):
    mobile = models.CharField(verbose_name="手机号", max_length=11)
    price = models.IntegerField(verbose_name="价格",default=100)
    level_choices=(
        (0,'青铜'),
        (1, '黄金'),
        (2, '白银'),
        (3, '钻石'),
        (4, '星耀'),
        (5, '王者'),
        (6, '最强王者'),
    )
    level = models.SmallIntegerField(verbose_name="级别",choices=level_choices,default=0)
    status_choices=(
        (1,'未使用'),
        (2,'已使用'),
    )
    status= models.SmallIntegerField(verbose_name="状态",choices=status_choices,default=1)


"""管理员"""
class Admin(models.Model):
    name = models.CharField(verbose_name="管理员姓名", max_length=32)
    password = models.CharField(verbose_name="管理员密码", max_length=64)
    def __str__(self):
        return self.name

"""任务表"""
class Task(models.Model):
    title = models.CharField(verbose_name="任务名称", max_length=64)
    level_choices=(
        (0,'紧急'),
        (1, '重要'),
        (2, '临时'),
    )
    level = models.SmallIntegerField(verbose_name="级别",choices=level_choices,default=0)
    detial = models.TextField(verbose_name="任务详情")
    user = models.ForeignKey(verbose_name="负责人",to="Admin",on_delete=models.CASCADE)


"""订单表"""
class Order(models.Model):

    oid= models.CharField(verbose_name="订单号", max_length=64)
    title= models.CharField(verbose_name="商品名称", max_length=64)
    price= models.IntegerField(verbose_name="商品价格")
    status_choicse=(
        (1,"待支付"),
        (2,"已支付")
    )
    status=models.SmallIntegerField(verbose_name="状态",choices=status_choicse, default=1)
    admin=models.ForeignKey(verbose_name="管理员",to="Admin",on_delete=models.CASCADE)